// client.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "client/comClient.h"
#include "client/gameLoopClient.h"
#include "stdlib.h"
#include "move.h"
#include "moves.h"
#include "moveGenerator.h"
#include <string>
#include <iostream>
#include "bitboard.h"
#include <vector>
#include "time.h"
#include "ai.h"

using namespace std;

GameLoopClient* gameLoop;
AI* ai;

Move chooseMove (Board currentBoard) {
	return ai->ChooseMove(gameLoop->Player, currentBoard);
}

int main(int argc, char* argv[])
{
	if(argc != 12) {
		cout << "Usage: client.exe [ip] [port] [identification] [maxDepth] [color] [w1] [w2] [w3] [w4] [w5] [w6]\n";
		system("pause");
		return 1;
	}

	ComClient* cc = new ComClient();
	cc->Connect(argv[1], atoi(argv[2]));

	// hloubku prohledavani zadavame v kolech, trida AI ji potrebuje v pultazich (indexovano od nuly)
	ai = new AI(atoi(argv[4])*2-1);
	
	// nacteni vahovych koeficientu
	for(int i = 0; i < 6; i++) {
		ai->weights[i] = atoi(argv[6 + i]);
	}

	// identifikacni retezec
	std::string identification = argv[3];
	std::string clientIdentity = "Client 1.0 (" + identification + ")";
	
	// barva
	CheckerColor player = (CheckerColor)(atoi(argv[5]));

	gameLoop = new GameLoopClient(cc, clientIdentity, player);
	gameLoop->chooseMove = &chooseMove;
	

	gameLoop->Run();

	return 0;
}

